﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WMSABL;
using WMSABL.SY;
using WMSAML.SY;
using ElectronicWMSA.Comm.Forms.MsControls;
using ElectronicWMSA.Comm.ClassFiles;
using ElectronicWMSA.Comm.Forms.Message;

namespace ElectronicWMSA.SY
{
    public partial class GroupRMFrm : Form
    {
        #region
        private int _Groupid = 0;
        private string strWhere = "";
        private string _GroupPemsissionStr = "";
        PublicDataSet bll_CommonPub = new PublicDataSet();
        TGroup_BLL bll_TGroup = new TGroup_BLL();
        TUsers_BLL bll_TUsers = new TUsers_BLL();
        TGroupRoleRelation_BLL bll_TGroupRoleRelation = new TGroupRoleRelation_BLL();
        TGroupPermissionRelation_BLL bll_TGroupPermissionRelation = new TGroupPermissionRelation_BLL();
        public GroupRMFrm()
        {
            InitializeComponent();
            this.strWhere = "";
            this.page1.PageCurrent = 1;
            this.page1.PageSize = 20;
            this.page1.Bind();
            this.DBind();
        }
        #endregion

        #region DBind
        public void DBind()
        {
            this.labShowSelectGroup.BackColor = Color.Transparent;
            this.labShowTop.BackColor = Color.Transparent;

            this.DBindTreeViewGroup();
            this.DBind_Roles();
            this.DBind_MenuMoudle();
            this.DBindPermisission();
        }
        #endregion

        #region 绑定组
        public void DBindTreeViewGroup()
        {
            this.treeViewGroupList.Nodes.Clear();
            DataSet ds = new DataSet();
            ds = bll_CommonPub.GetDataSet("TGroup", "");
            DataTable dt = ds.Tables[0];
            TreeNode node = new TreeNode();
            node.Name = "0";
            node.Text = "组列表";
            treeViewGroupList.Nodes.Add(node);
            this.AddNodes(dt, node);
            this.treeViewGroupList.ExpandAll();
            this.treeViewGroupList.SelectedNode = treeViewGroupList.TopNode; //最顶端节点选中
        }

        /// <summary>
        /// AddNodes
        /// </summary>
        /// <param name="dt">dt</param>
        /// <param name="node">node</param>
        public void AddNodes(DataTable dt, TreeNode node)
        {
            DataView dv = new DataView(dt);
            dv.RowFilter = "Parent_id='" + node.Name + "'";
            foreach (DataRowView row in dv)
            {
                TreeNode replyNode = new TreeNode();
                replyNode.Text = row["Group_name"].ToString();
                replyNode.Name = row["Group_id"].ToString();
                node.Nodes.Add(replyNode);
                this.AddNodes(dt, replyNode);
            }
        } 
        #endregion

        #region 绑定角色
        public void DBind_Roles()
        {
            this.treeViewUserRoles.Nodes.Clear();
            DataSet ds = new DataSet();
            ds = bll_CommonPub.GetDataSet("TRoles", "");
            DataTable dt = ds.Tables[0];
            TreeNode node = new TreeNode();
            node.Name = "0";
            node.Text = "角色管理";
            treeViewUserRoles.Nodes.Add(node);
            this.AddNodes_Roles(dt, node);
            this.treeViewUserRoles.ExpandAll();
            this.treeViewUserRoles.SelectedNode = this.treeViewUserRoles.TopNode; //最顶端节点选中
        }

        public void AddNodes_Roles(DataTable dt, TreeNode node)
        {
            DataView dv = new DataView(dt);
            dv.RowFilter = "Parent_id='" + node.Name + "'";
            foreach (DataRowView row in dv)
            {
                TreeNode replyNode = new TreeNode();
                replyNode.Text = row["Role_name"].ToString();
                replyNode.Name = row["Role_id"].ToString();
                node.Nodes.Add(replyNode);
                this.AddNodes_Roles(dt, replyNode);
            }
        }
        #endregion

        #region 绑定权限
        TSystemRegistBLL bll_SystemRegist = new TSystemRegistBLL();
        public void DBind_MenuMoudle()
        {
            this.treeViewMenuPermission.Nodes.Clear();
            DataSet ds = new DataSet();
            ds = bll_SystemRegist.GetList_SystemMeun();
            DataTable dt = new DataTable();
            dt = ds.Tables[0];
            DataView dv = new DataView(dt);
            dv.RowFilter = "headID=0";
            foreach (DataRowView drv in dv)
            {
                TreeNode node = new TreeNode();
                node.Text = drv["Menu_Name"].ToString();
                node.Name = drv["ID"].ToString();
                node.ImageIndex = 0;
                node.SelectedImageIndex = 0;
                this.treeViewMenuPermission.Nodes.Add(node);
                this.AddPermisissionsNodes(dt, node);
            }
            this.treeViewMenuPermission.Nodes[0].Expand();
        }

        /// <summary>
        /// AddNodes
        /// </summary>
        /// <param name="dt">dt</param>
        /// <param name="node">node</param>
        public void AddPermisissionsNodes(DataTable dt, TreeNode node)
        {
            DataView dv = new DataView(dt);
            dv.RowFilter = "headID='" + node.Name + "'";
            foreach (DataRowView row in dv)
            {
                TreeNode replyNode = new TreeNode();
                replyNode.Text = row["Menu_Name"].ToString();
                replyNode.Name = row["ID"].ToString();
                node.ImageIndex = 1;
                node.SelectedImageIndex = 1;
                node.Nodes.Add(replyNode);
                AddPermisissionsNodes(dt, replyNode);
            }
        }

        #endregion

        #region 绑定权限列表
        public void DBindPermisission()
        {
            DataSet ds = new DataSet();
            ds = bll_CommonPub.GetDataSet("TDictionary_Category", " SortID=1 ");
            dataGridViewMoudlePermisissionList.DataSource = ds.Tables[0].DefaultView;
        }

        private void dataGridViewMoudlePermisissionList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
                this.dataGridViewMoudlePermisissionList.Rows[e.RowIndex].Selected = true;
        }

        #endregion


        #region 绑定用户列表
        public int DBind_dataGridViewUserList()
        {
            ElectronicWMSA.Comm.Forms.MsControls.PageData pageData = new ElectronicWMSA.Comm.Forms.MsControls.PageData();
            pageData.TableName = "Vlh_TUserListByGroupid";
            pageData.PrimaryKey = "User_id";
            pageData.OrderStr = "User_id";
            pageData.PageIndex = this.page1.PageCurrent;
            pageData.PageSize = this.page1.PageSize;
            pageData.QueryCondition = strWhere;
            pageData.QueryFieldName = "*";

            this.page1.bindingSource.DataSource = pageData.QueryDataTable().Tables[0];
            this.page1.bindingNavigator.BindingSource = page1.bindingSource;
            this.dataGridViewUserList.AutoGenerateColumns = false;
            this.dataGridViewUserList.DataSource = this.page1.bindingSource;
            this.dataGridViewUserList.ClearSelection();
            return pageData.TotalCount;
        }

        private int pageControlGroupUserList_EventPaging(ElectronicWMSA.Comm.Forms.MsControls.EventPagingArg e)
        {
            return DBind_dataGridViewUserList();
        }

        private void dataGridViewUserList_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            SolidBrush b = new SolidBrush(dataGridViewUserList.RowHeadersDefaultCellStyle.ForeColor);
            e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), dataGridViewUserList.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);

        }
        #endregion

        #region 组管理
        #region 组新增
        private void btnGroupListAdd_Click(object sender, EventArgs e)
        {
            if (!SystemVariable.VaildationPermission("新增")) return;

            string groupName = this.txtGroupAddName.Text.Trim();
            if (groupName == "")
            {
                labGroupAddShow.Text = "组名称不能为空！";
                this.txtGroupAddName.Focus();
                return;
            }
            if (bll_TGroup.ExistsByName(groupName))
            {
                labGroupAddShow.Text = "组名称已经存在！";
                this.txtGroupAddName.Focus();
                return;
            }
            TGroup_Entity entity = new TGroup_Entity();
            entity.Group_name = groupName;
            entity.Creat_time = DateTime.Now;
            entity.Description = txtGroupAddMark.Text.Trim();
            if (MessageClass.enquire("确认添加信息！") == DialogResult.OK)
            {
                if (bll_TGroup.Add(entity))
                {
                    MessageClass.right("成功！");
                    this.btnGroupListClear_Click(sender, e);
                }
                else
                {
                    MessageClass.error("添失败！");
                }
            }
        }
        #endregion

        #region 组修改
        private void btnGroupListUpdate_Click(object sender, EventArgs e)
        {
            if (!SystemVariable.VaildationPermission("编辑")) return;

            string groupName = this.txtGroupAddName.Text.Trim();
            if (groupName == "")
            {
                labGroupAddShow.Text = "组名称不能为空！";
                this.txtGroupAddName.Focus();
                return;
            }
            DataSet ds = bll_CommonPub.GetDataSet("TGroup", " Group_name='" + groupName + "'  AND Group_id!='" + _Groupid + "'");
            int count = 0;
            if (ds.Tables[0].Rows.Count > 0)
            {
                count = ds.Tables[0].Rows.Count;
            }
            if (count > 0)
            {
                labGroupAddShow.Text = "组名称已经存在！";
                this.txtGroupAddName.Focus();
                return;
            }
            TGroup_Entity entity = new TGroup_Entity();
            entity.Group_id = _Groupid;
            entity.Group_name = groupName;
            entity.Creat_time = DateTime.Now;
            entity.Description = txtGroupAddMark.Text.Trim();
            if (MessageClass.enquire("确认修改信息！") == DialogResult.OK)
            {
                if (bll_TGroup.Update(entity))
                {
                    MessageClass.right("成功！");
                    this.btnGroupListClear_Click(sender, e);
                }
                else
                {
                    MessageClass.error("失败！");
                }
            }
        }
        #endregion

        #region 组删除
        private void btnGroupDelete_Click(object sender, EventArgs e)
        {
            if (!SystemVariable.VaildationPermission("删除")) return;

            if (_Groupid <= 0)
            {
                MessageClass.error("请选择组！");
                return;
            }
            //需判断是否引用才能删除
            DataSet ds = new DataSet();
            if (bll_CommonPub.GetDataSet("TUserGroupRelation", "Group_id='" + _Groupid + "'") != null)
            {
                MessageClass.error("该组别已分配用户，不能删除！");
                return;
            }
            if (bll_CommonPub.GetDataSet("TGroupRoleRelation", "Group_id='" + _Groupid + "'") != null)
            {
                MessageClass.error("该组别已分配角色，不能删除！");
                return;
            }
            if (bll_CommonPub.GetDataSet("TGroupPermissionRelation", "Group_id='" + _Groupid + "'") != null)
            {
                MessageClass.error("该组别已分配权限，不能删除！");
                return;
            }
            if (MessageClass.enquire("确认删除组！") == DialogResult.OK)
            {
                if (bll_TGroup.Delete(_Groupid))
                {
                    MessageClass.right("成功！");
                    this.btnGroupListClear_Click(sender, e);
                }
                else
                {
                    MessageClass.error("失败！");
                }
            }
        }
        #endregion

        #region 组重置
        private void btnGroupListClear_Click(object sender, EventArgs e)
        {
            this._Groupid = 0;
            this.txtGroupAddName.Text = "";
            this.txtGroupAddMark.Text = "";
            this.labGroupAddShow.Text = "信息提示！";
            this.DBindTreeViewGroup();
        }
        #endregion
        #endregion

        #region 移除用户
        private void dataGridViewUserList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                #region 确认删除
                if (e.ColumnIndex != -1 && this.dataGridViewUserList.CurrentCell.ColumnIndex == 0)
                {
                    if (!SystemVariable.VaildationPermission("删除")) return;
                    int uid = Convert.ToInt32(dataGridViewUserList.CurrentRow.Cells["User_id"].Value.ToString());
                    if (uid == 2)
                    {
                        MessageClass.error("此用户不能删除！");
                        return;
                    }
                    if (MessageClass.enquire("确定删除信息！") == DialogResult.OK)
                    {
                        TUserGroupRelation_BLL bll_TUserGroupRelation = new TUserGroupRelation_BLL();
                        if (bll_TUserGroupRelation.Delete(uid, _Groupid))
                        {
                            this.dataGridViewUserList.Rows.RemoveAt(e.RowIndex);
                        }
                        else
                        {
                            MessageClass.error("失败！");
                        }
                    }
                }
                #endregion
            }
        }
        #endregion

        #region 获取选中组分配角色
        public string roles_idStr = "";
        public void GetstrRoles()
        {
            this.roles_idStr = "";
            foreach (TreeNode tn in this.treeViewUserRoles.Nodes)
            {
                GetstrRoles_Nodes(tn);
            }
        }
        public void GetstrRoles_Nodes(TreeNode node)
        {
            if (node.Checked)
            {
                if (node.Name != "0")
                {
                    roles_idStr += node.Name + ",";
                }
            }
            foreach (TreeNode tn in node.Nodes)
            {
                GetstrRoles_Nodes(tn);
            }
        }
        #endregion

        #region 组角色保存
        private void btnGroupPemsissionSave_Click(object sender, EventArgs e)
        {
            if (!SystemVariable.VaildationPermission("编辑")) return;
            this.GetstrRoles();
            if (_Groupid <= 0)
            {
                MessageClass.error("请选择组！");
                return;
            }
            if (MessageClass.enquire("确认保存信息！") == DialogResult.OK)
            {
                if (bll_TGroupRoleRelation.Update_TGroupRoleRelation(_Groupid, roles_idStr))
                {
                    MessageClass.right("成功！");
                    SystemVariable.Vaidation(SystemVariable.User_ID);
                }
                else
                {
                    MessageClass.error("失败！");
                }
            }
        }
        #endregion

        #region 设置权限
        private void btnPemsissionSave_Click(object sender, EventArgs e)
        {
            if (!SystemVariable.VaildationPermission("编辑")) return;

            if (_Groupid == 0) { MessageClass.error("请选择组！"); return; }

            if (rbALLPermissions.Checked || rbDelALLPermissions.Checked)
            {
                if (rbALLPermissions.Checked)
                {
                    string str = bll_CommonPub.GetTPermissionStr();
                    if (str != "")
                        _GroupPemsissionStr = str;
                }
                if (rbDelALLPermissions.Checked)
                    _GroupPemsissionStr = "";
            }
            else
            {
                if (moudleid == 0) { MessageClass.error("请选择模块权限！"); return; }
                this.GetPermisissionStr();
            }
            if (MessageClass.enquire("确认保存信息！") == DialogResult.OK)
            {
                if (bll_TGroupPermissionRelation.AddTGroupPermissionRelation(_Groupid, _GroupPemsissionStr))
                {
                    SystemVariable.AddLogInfo("组别权限设置", "组ID" + _Groupid + "权限设置。");
                    MessageClass.right("成功！");
                    this.GetGroupPermisissionStr(_Groupid);
                    SystemVariable.Vaidation(SystemVariable.User_ID);
                    if (moudleid > 0)
                    {
                        this.treeViewMenuPermissionClik(moudleid);
                    }
                    rbALLPermissions.Checked = false;
                    rbDelALLPermissions.Checked = false;
                }
                else
                {
                    MessageClass.error("失败！");
                }
            }
        }
        /// 获取选中权限 
        public void GetPermisissionStr()
        {
            this._GroupPemsissionStr = "";
            this.strNewpers = "";
            if (strOldpers != "")
            {
                string[] arryStrOldpers = strOldpers.Split(',');
                for (int y = 0; y < arryStrOldpers.Length - 1; y++)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (list[i] == arryStrOldpers[y])
                        {
                            list.Remove(list[i]);
                            break;
                        }
                    }
                }
            }

            for (int i = 0; i < dataGridViewMoudlePermisissionList.Rows.Count; i++)
            {
                if ((bool)dataGridViewMoudlePermisissionList.Rows[i].Cells[0].Value)
                {
                    strNewpers += dataGridViewMoudlePermisissionList.Rows[i].Cells[1].Value.ToString() + ",";
                }
            }

            if (strNewpers != "")
            {
                foreach (var item in strNewpers.Split(','))
                {
                    list.Add(item);
                }
            }
            _GroupPemsissionStr = string.Join(",", list.ToArray());
        }
        #endregion

        #region 自动选择父节点
        private void treeViewUserRoles_AfterCheck(object sender, TreeViewEventArgs e)
        {
            if (e.Action != TreeViewAction.Unknown)
            {
                this.SetNodeCheckStatus(e.Node, e.Node.Checked);
                this.SetNodeStyle(e.Node);
            }
        }

        #region AfterCheck
        /// <summary>
        /// SetNodeCheckStatus
        /// </summary>
        private void SetNodeCheckStatus(TreeNode tn, bool Checked)
        {
            if (tn == null) return;
            foreach (TreeNode tnChild in tn.Nodes)
            {
                tnChild.Checked = Checked;
                SetNodeCheckStatus(tnChild, Checked);
            }
            TreeNode tnParent = tn;
        }
        /// <summary>
        /// SetNodeStyle
        /// </summary>
        private void SetNodeStyle(TreeNode Node)
        {
            int nNodeCount = 0;
            if (Node.Nodes.Count != 0)
            {
                foreach (TreeNode tnTemp in Node.Nodes)
                {
                    if (tnTemp.Checked == true)
                        nNodeCount++;
                }

                if (nNodeCount == Node.Nodes.Count)
                {
                    Node.Checked = true;
                    Node.ExpandAll();
                    Node.ForeColor = Color.Black;
                }
                else if (nNodeCount == 0)
                {
                    Node.Checked = false;
                    Node.Collapse();
                    Node.ForeColor = Color.Black;
                }
                else
                {
                    Node.Checked = true;
                    Node.ForeColor = Color.Gray;
                }
            }
            //当前节点选择完后，判断父节点的状态，调用此方法递归。  
            if (Node.Parent != null)
                SetNodeStyle(Node.Parent);
        }
        #endregion

        #endregion

        #region 模块权限事件
        List<string> list;
        private int moudleid = 0;
        private string strOldpers = "";
        private string strNewpers = "";
        private string[] arryPermisission = null;
        private void treeViewMenuPermission_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (_Groupid == 0) { MessageClass.error("未选中组！"); return; }
            rbALLPermissions.Checked = false;
            rbDelALLPermissions.Checked = false;
            this.GetGroupPermisissionStr(_Groupid);

            if (e.Node.LastNode == null)
            {
                moudleid = Convert.ToInt32(e.Node.Name);
                treeViewMenuPermissionClik(moudleid);
            }
        }

        public void treeViewMenuPermissionClik(int moudleid)
        {
            strOldpers = "";

            #region 模块对应所具有权限
            DataSet ds1 = new DataSet();
            ds1 = bll_CommonPub.GetDataSet("SELECT a.ID, '' AS sortID, b.Value FROM  dbo.TPermissions AS a LEFT OUTER JOIN dbo.TDictionary_Category AS b ON a.Type = b.ID WHERE (a.MoudleID = " + moudleid + " ) AND (a.Display = 1)");
            if (ds1.Tables[0].Rows.Count > 0)
            {
                dataGridViewMoudlePermisissionList.DataSource = ds1.Tables[0].DefaultView;
                this.dataGridViewMoudlePermisissionList.ClearSelection();
            }
            else
            {
                DataSet ds2 = bll_CommonPub.GetDataSet("SELECT TOP 1 * FROM DBO.TDictionary_Category WHERE SortID=1  ");
                DataTable dt = new DataTable();
                dt = ds2.Tables[0];
                dt.Rows.Clear();
                this.dataGridViewMoudlePermisissionList.DataSource = dt;
                MessageClass.error("该模块未分配权限！");
                return;
            }
            #endregion

            #region 取值勾选
            DataSet ds3 = new DataSet();
            ds3 = bll_CommonPub.GetDataSet("TPermissions", "moudleid=" + moudleid + " AND Display = 1");
            int id = 0;
            if (ds3.Tables[0].Rows.Count > 0)
            {
                for (int y = 0; y < ds3.Tables[0].Rows.Count; y++)
                {
                    id = Convert.ToInt32(ds3.Tables[0].Rows[y]["ID"].ToString());
                    if (arryPermisission != null)
                    {
                        for (int i = 0; i < arryPermisission.Length - 1; i++)
                        {
                            if (arryPermisission[i] == id.ToString())
                            {
                                dataGridViewMoudlePermisissionList.Rows[y].Cells[0].Value = true;
                                strOldpers += dataGridViewMoudlePermisissionList.Rows[y].Cells[1].Value + ",";
                                break;
                            }
                            else
                            {
                                dataGridViewMoudlePermisissionList.Rows[y].Cells[0].Value = false;
                            }
                        }
                    }
                    else
                    {
                        this.dataGridViewMoudlePermisissionList.Rows[y].Cells[0].Value = false;
                    }
                }
            }
            #endregion
        }
        #region 获取初始权限，List
        public void GetGroupPermisissionStr(int groupid)
        {
            list = new List<string>();
            arryPermisission = null;

            DataSet ds_Pemsission = new DataSet();
            ds_Pemsission = bll_CommonPub.GetDataSet("TGroupPermissionRelation", "Group_id='" + groupid + "'");
            if (ds_Pemsission.Tables[0].Rows.Count == 0)
                return;
            string permission_idStr = ds_Pemsission.Tables[0].Rows[0]["Permission_id"].ToString();
            if (permission_idStr != "")
            {
                arryPermisission = permission_idStr.Split(',');
                foreach (var item in permission_idStr.Substring(0, permission_idStr.Length - 1).Split(','))
                {
                    list.Add(item);
                }
            }
        }
        #endregion

        #endregion

        #region 组菜单事件
        private void treeViewGroupList_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Node.Nodes.Count < 0) return;
            this._Groupid = Convert.ToInt32(e.Node.Name);
            this.DBind_Roles();
            this.GetGroupPermisissionStr(_Groupid);
            this.moudleid = 0;
            this.txtGroupAddName.Text = "";
            this.txtGroupAddMark.Text = "";
            rbALLPermissions.Checked = false;
            rbDelALLPermissions.Checked = false;
            #region 组管理
            TGroup_Entity entity = new TGroup_Entity();
            entity = bll_TGroup.GetEntityByID(_Groupid);
            this._Groupid = Convert.ToInt32(e.Node.Name);
            if (entity == null) return;
            this.txtGroupAddName.Text = entity.Group_name;
            this.txtGroupAddMark.Text = entity.Description;
            #endregion

            #region 组包含用户列表
            if (_Groupid > 0)
            {
                this.strWhere = "Group_id= '" + _Groupid + "'";
                this.labShowSelectGroup.Text = "所选组:" + e.Node.Text + "";
            }
            else
            {
                this.strWhere = "";
                this.labShowSelectGroup.Text = "所选组:";
            }
            this.page1.Bind();
            #endregion

            #region 组包含角色
            DataSet ds = new DataSet();
            ds = bll_CommonPub.GetDataSet("Vlh_GetGRR_RidStr", "Group_id='" + _Groupid + "'");
            if (ds.Tables[0].Rows.Count == 0) return;
            string[] rolesArryList = ds.Tables[0].Rows[0]["RolesStr"].ToString().Split(',');
            if (treeViewUserRoles.Nodes.Count == 0) return;
            for (int y = 0; y < rolesArryList.Length; y++)
            {
                string role_Name = rolesArryList[y];
                foreach (TreeNode td in treeViewUserRoles.Nodes)
                {
                    TreeNode targetNode = SearchNode(td, role_Name);
                    if (targetNode != null) targetNode.Checked = true;
                }
            }
            #endregion

            this.labGroupAddShow.Text = "信息提示！";
        }

        #region 获取节点
        private TreeNode SearchNode(TreeNode td, string nodetxt)
        {
            if (td.Name == nodetxt)
            {
                return td;
            }
            TreeNode targetNode = null;
            foreach (TreeNode childNodes in td.Nodes)
            {
                targetNode = SearchNode(childNodes, nodetxt);
                if (targetNode != null)
                    break;
            }
            return targetNode;
        }
        #endregion
        #endregion

        #region 退出
        private void linkLabelClose_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Main._Main.CloseTabPages();
        }

        private void linkLabellinkLabelCloseAll_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Main._Main.CloseAllTabPages();
        }

        private void linkLabelCloseElse_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Main._Main.CloseTabPageElse();
        }
        #endregion

    }
}
